package lab22;

public class Ship implements Comparable<Ship> {

	private int capacity;
	private int crew;
	private int numSavingBoats;
	private String captain;
	private String shipName;

	public Ship() {
		shipName = "";
		captain = "";
	}

	public Ship(int capacity, int crew, int numSavingBoats, String captain,
			String shipName) {
		super();
		this.capacity = capacity;
		this.crew = crew;
		this.numSavingBoats = numSavingBoats;
		this.captain = captain;
		this.shipName = shipName;
	}

	/**
	 * @return the capacity
	 */
	public int getCapacity() {
		return capacity;
	}

	/**
	 * @param capacity
	 *            the capacity to set
	 */
	public void setCapacity(int capacity) {
		this.capacity = capacity;
	}

	/**
	 * @return the crew
	 */
	public int getCrew() {
		return crew;
	}

	/**
	 * @param crew
	 *            the crew to set
	 */
	public void setCrew(int crew) {
		this.crew = crew;
	}

	/**
	 * @return the numSavingBoats
	 */
	public int getNumSavingBoats() {
		return numSavingBoats;
	}

	/**
	 * @param numSavingBoats
	 *            the numSavingBoats to set
	 */
	public void setNumSavingBoats(int numSavingBoats) {
		this.numSavingBoats = numSavingBoats;
	}

	/**
	 * @return the captain
	 */
	public String getCaptain() {
		return captain;
	}

	/**
	 * @param captain
	 *            the captain to set
	 */
	public void setCaptain(String captain) {
		this.captain = captain;
	}

	/**
	 * @return the shipName
	 */
	public String getShipName() {
		return shipName;
	}

	/**
	 * @param shipName
	 *            the shipName to set
	 */
	public void setShipName(String shipName) {
		this.shipName = shipName;
	}

	@Override
	public int compareTo(Ship otherShip) {
		if (otherShip != null)
			return this.capacity*this.crew - otherShip.getCapacity()*otherShip.getCrew();
		return 1;
	}
	
	@Override
	public String toString() {
		return shipName;
	}

	@Override
	public boolean equals(Object otherShip) {
		return this.shipName.equals(((Ship)otherShip).getShipName());
	}
	
	@Override
	public int hashCode() {
		return this.shipName.hashCode();
	}
}
